home *** CD-ROM | disk | FTP | other *** search
/ Enter 2007 April / ENTER_CD_04_07.iso / Internet / WinHTTrack 3.23 / httrack-3.23.exe / {app} / src / httrack.c < prev    next >
Encoding:
C/C++ Source or Header  |  2003-03-08  |  18.6 KB  |  611 lines

  1. /* ------------------------------------------------------------ */
  2. /*
  3. HTTrack Website Copier, Offline Browser for Windows and Unix
  4. Copyright (C) Xavier Roche and other contributors
  5.  
  6. This program is free software; you can redistribute it and/or
  7. modify it under the terms of the GNU General Public License
  8. as published by the Free Software Foundation; either version 2
  9. of the License, or any later version.
  10.  
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with this program; if not, write to the Free Software
  18. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  19.  
  20.  
  21. Important notes:
  22.  
  23. - We hereby ask people using this source NOT to use it in purpose of grabbing
  24. emails addresses, or collecting any other private information on persons.
  25. This would disgrace our work, and spoil the many hours we spent on it.
  26.  
  27.  
  28. Please visit our Website: http://www.httrack.com
  29. */
  30.  
  31.  
  32. /* ------------------------------------------------------------ */
  33. /* File: htsshow.c console progress info                        */
  34. /* Only used on Linux version                                   */
  35. /* Author: Xavier Roche                                         */
  36. /* ------------------------------------------------------------ */
  37.  
  38. #ifndef _WIN32
  39. #ifndef Sleep
  40. #define Sleep(a) { if (((a)*1000)%1000000) usleep(((a)*1000)%1000000); if (((a)*1000)/1000000) sleep(((a)*1000)/1000000); }
  41. #endif
  42. #endif
  43.  
  44. #include "htsglobal.h"
  45. #include "httrack.h"
  46.  
  47. // htswrap_add
  48. #include "htswrap.h"
  49.  
  50. #if HTS_ANALYSTE_CONSOLE
  51.  
  52. /* specific definitions */
  53. //#include "htsbase.h"
  54. #include <stdio.h>
  55. #include <stdlib.h>
  56. #include <string.h>
  57. #ifdef HAVE_SYS_TYPES_H
  58. #include <sys/types.h>
  59. #endif
  60. #ifdef HAVE_SYS_STAT_H
  61. #include <sys/stat.h>
  62. #endif
  63. #ifdef HAVE_UNISTD_H
  64. #include <unistd.h>
  65. #endif
  66. #include <ctype.h>
  67. #ifdef _WIN32
  68. //#include "Winsock.h"
  69. #endif
  70. /* END specific definitions */
  71.  
  72. // ISO VT100/220 definitions
  73. #define VT_COL_TEXT_BLACK    "30"
  74. #define VT_COL_TEXT_RED      "31"
  75. #define VT_COL_TEXT_GREEN    "32"
  76. #define VT_COL_TEXT_YELLOW   "33"
  77. #define VT_COL_TEXT_BLUE     "34"
  78. #define VT_COL_TEXT_MAGENTA  "35"
  79. #define VT_COL_TEXT_CYAN     "36"
  80. #define VT_COL_TEXT_WHITE    "37"
  81. #define VT_COL_BACK_BLACK    "40"
  82. #define VT_COL_BACK_RED      "41"
  83. #define VT_COL_BACK_GREEN    "42"
  84. #define VT_COL_BACK_YELLOW   "43"
  85. #define VT_COL_BACK_BLUE     "44"
  86. #define VT_COL_BACK_MAGENTA  "45"
  87. #define VT_COL_BACK_CYAN     "46"
  88. #define VT_COL_BACK_WHITE    "47"
  89. //
  90. #define VT_GOTOXY(X,Y)  "\33["Y";"X"f"
  91. #define VT_COLOR(C)     "\33["C"m"
  92. #define VT_RESET        "\33[m"
  93. #define VT_REVERSE      "\33[7m"
  94. #define VT_UNREVERSE    "\33[27m"
  95. #define VT_BOLD         "\33[1m"
  96. #define VT_UNBOLD       "\33[22m"
  97. #define VT_BLINK        "\33[5m"
  98. #define VT_UNBLINK      "\33[25m"
  99. //
  100. #define VT_CLREOL       "\33[K"
  101. #define VT_CLRSOL       "\33[1K"
  102. #define VT_CLRLIN       "\33[2K"
  103. #define VT_CLREOS       "\33[J"
  104. #define VT_CLRSOS       "\33[1J"
  105. #define VT_CLRSCR       "\33[2J"
  106. //
  107. #define csi(X)          printf(s_csi( X ));
  108. void vt_clear(void) {
  109.   printf("%s%s%s",VT_RESET,VT_CLRSCR,VT_GOTOXY("1","0"));
  110. }
  111. void vt_home(void) {
  112.   printf("%s%s",VT_RESET,VT_GOTOXY("1","0"));
  113. }
  114. //
  115.  
  116.  
  117. /*
  118. #define STYLE_STATVALUES VT_COLOR(VT_COL_TEXT_BLACK)
  119. #define STYLE_STATTEXT   VT_COLOR(VT_COL_TEXT_BLUE)   
  120. */
  121. #define STYLE_STATVALUES VT_BOLD
  122. #define STYLE_STATTEXT   VT_UNBOLD
  123. #define STYLE_STATRESET  VT_UNBOLD
  124. #define NStatsBuffer     14
  125. #define MAX_LEN_INPROGRESS 40
  126.  
  127. static int use_show;
  128.  
  129. int main(int argc, char **argv) {
  130.   hts_init();
  131.  
  132.   /*
  133.   hts_htmlcheck_init         = (t_hts_htmlcheck_init)           htswrap_read("init");
  134. Log: "engine: init"
  135.  
  136.   hts_htmlcheck_uninit       = (t_hts_htmlcheck_uninit)         htswrap_read("free");
  137. Log: "engine: free"
  138.  
  139.   hts_htmlcheck_start        = (t_hts_htmlcheck_start)          htswrap_read("start");
  140. Log: "engine: start"
  141.  
  142.   hts_htmlcheck_end          = (t_hts_htmlcheck_end)            htswrap_read("end");
  143. Log: "engine: end"
  144.  
  145.   hts_htmlcheck_chopt        = (t_hts_htmlcheck_chopt)          htswrap_read("change-options");
  146. Log: "engine: change-options"
  147.  
  148.   hts_htmlcheck              = (t_hts_htmlcheck)                htswrap_read("check-html");
  149. Log: "check-html: <url>"
  150.  
  151.   hts_htmlcheck_query        = (t_hts_htmlcheck_query)          htswrap_read("query");
  152.   hts_htmlcheck_query2       = (t_hts_htmlcheck_query2)         htswrap_read("query2");
  153.   hts_htmlcheck_query3       = (t_hts_htmlcheck_query3)         htswrap_read("query3");
  154.   hts_htmlcheck_loop         = (t_hts_htmlcheck_loop)           htswrap_read("loop");
  155.   hts_htmlcheck_check        = (t_hts_htmlcheck_check)          htswrap_read("check-link");
  156. Log: none
  157.  
  158.   hts_htmlcheck_pause        = (t_hts_htmlcheck_pause)          htswrap_read("pause");
  159. Log: "pause: <lockfile>"
  160.  
  161.   hts_htmlcheck_filesave     = (t_hts_htmlcheck_filesave)       htswrap_read("save-file");
  162.   hts_htmlcheck_linkdetected = (t_hts_htmlcheck_linkdetected)   htswrap_read("link-detected");
  163. Log: none
  164.  
  165.   hts_htmlcheck_xfrstatus    = (t_hts_htmlcheck_xfrstatus)      htswrap_read("transfer-status");
  166. Log: 
  167.     "engine: transfer-status: link updated: <url> -> <file>"
  168.   | "engine: transfer-status: link added: <url> -> <file>"
  169.   | "engine: transfer-status: link recorded: <url> -> <file>"
  170.   | "engine: transfer-status: link link error (<errno>, '<err_msg>'): <url>"
  171.   hts_htmlcheck_savename     = (t_hts_htmlcheck_savename  )     htswrap_read("save-name");
  172. Log: 
  173.     "engine: save-name: local name: <url> -> <file>"
  174. */
  175.   
  176.   htswrap_add("init",htsshow_init);
  177.   htswrap_add("free",htsshow_uninit);
  178.   htswrap_add("start",htsshow_start);
  179.   htswrap_add("change-options",htsshow_chopt);
  180.   htswrap_add("end",htsshow_end);
  181.   htswrap_add("check-html",htsshow_checkhtml);
  182.   htswrap_add("loop",htsshow_loop);
  183.   htswrap_add("query",htsshow_query);
  184.   htswrap_add("query2",htsshow_query2);
  185.   htswrap_add("query3",htsshow_query3);
  186.   htswrap_add("check-link",htsshow_check);
  187.   htswrap_add("pause",htsshow_pause);
  188.   htswrap_add("save-file",htsshow_filesave);
  189.   htswrap_add("link-detected",htsshow_linkdetected);
  190.   htswrap_add("transfer-status",htsshow_xfrstatus);
  191.   htswrap_add("save-name",htsshow_savename);
  192.  
  193.   return hts_main(argc,argv);
  194. }
  195.  
  196.  
  197. /* CALLBACK FUNCTIONS */
  198.  
  199. /* Initialize the Winsock */
  200. void __cdecl htsshow_init(void) {
  201. #ifdef _WIN32
  202.   {
  203.     WORD   wVersionRequested;   // requested version WinSock API
  204.     WSADATA wsadata;            // Windows Sockets API data
  205.     int stat;
  206.     wVersionRequested = 0x0101;
  207.     stat = WSAStartup( wVersionRequested, &wsadata );
  208.     if (stat != 0) {
  209.       printf("Winsock not found!\n");
  210.       return;
  211.     } else if (LOBYTE(wsadata.wVersion) != 1  && HIBYTE(wsadata.wVersion) != 1) {
  212.       printf("WINSOCK.DLL does not support version 1.1\n");
  213.       WSACleanup();
  214.       return;
  215.     }
  216.   }
  217. #endif
  218.  
  219. }
  220. void __cdecl htsshow_uninit(void) {
  221. #ifdef _WIN32
  222.   WSACleanup();
  223. #endif
  224. }
  225. int __cdecl htsshow_start(httrackp* opt) {
  226.   use_show=0;
  227.   if (opt->verbosedisplay==2) {
  228.     use_show=1;
  229.     vt_clear();
  230.   }
  231.   return 1; 
  232. }
  233. int __cdecl htsshow_chopt(httrackp* opt) {
  234.   return htsshow_start(opt);
  235. }
  236. int  __cdecl htsshow_end(void) { 
  237.   return 1; 
  238. }
  239. int __cdecl htsshow_checkhtml(char* html,int len,char* url_adresse,char* url_fichier) {
  240.   return 1;
  241. }
  242. int __cdecl htsshow_loop(lien_back* back,int back_max,int back_index,int lien_n,int lien_tot,int stat_time, hts_stat_struct* stats) {    // appelΘ α chaque boucle de HTTrack
  243.   static TStamp prev_mytime=0; /* ok */
  244.   static t_InpInfo SInfo; /* ok */
  245.   //
  246.   TStamp mytime;
  247.   long int rate=0;
  248.   char st[256];
  249.   //
  250.   int stat_written=-1;
  251.   int stat_updated=-1;
  252.   int stat_errors=-1;
  253.   int stat_warnings=-1;
  254.   int stat_infos=-1;
  255.   int nbk=-1;
  256.   LLint nb=-1;
  257.   int stat_nsocket=-1;
  258.   LLint stat_bytes=-1;
  259.   LLint stat_bytes_recv=-1;
  260.   int irate=-1;
  261.   if (stats) {
  262.     stat_written=stats->stat_files;
  263.     stat_updated=stats->stat_updated_files;
  264.     stat_errors=stats->stat_errors;
  265.     stat_warnings=stats->stat_warnings;
  266.     stat_infos=stats->stat_infos;
  267.     nbk=stats->nbk;
  268.     stat_nsocket=stats->stat_nsocket;
  269.     irate=(int)stats->rate;
  270.     nb=stats->nb;
  271.     stat_bytes=stats->nb;
  272.     stat_bytes_recv=stats->HTS_TOTAL_RECV;
  273.   }
  274.  
  275.   if (!use_show)
  276.     return 1;
  277.  
  278.   mytime=mtime_local();
  279.   if ((stat_time>0) && (stat_bytes_recv>0))
  280.     rate=(int)(stat_bytes_recv/stat_time);
  281.   else
  282.     rate=0;    // pas d'infos
  283.  
  284.   /* Infos */
  285.   if (stat_bytes>=0) SInfo.stat_bytes=stat_bytes;      // bytes
  286.   if (stat_time>=0) SInfo.stat_time=stat_time;         // time
  287.   if (lien_tot>=0) SInfo.lien_tot=lien_tot; // nb liens
  288.   if (lien_n>=0) SInfo.lien_n=lien_n;       // scanned
  289.   SInfo.stat_nsocket=stat_nsocket;          // socks
  290.   if (rate>0)  SInfo.rate=rate;                // rate
  291.   if (irate>=0) SInfo.irate=irate;             // irate
  292.   if (SInfo.irate<0) SInfo.irate=SInfo.rate;
  293.   if (SInfo.stat_back>=0) SInfo.stat_back=nbk;
  294.   if (stat_written>=0) SInfo.stat_written=stat_written;
  295.   if (stat_updated>=0) SInfo.stat_updated=stat_updated;
  296.   if (stat_errors>=0)  SInfo.stat_errors=stat_errors;
  297.   if (stat_warnings>=0)  SInfo.stat_warnings=stat_warnings;
  298.   if (stat_infos>=0)  SInfo.stat_infos=stat_infos;
  299.  
  300.  
  301.   if ( ((mytime - prev_mytime)>100) || ((mytime - prev_mytime)<0) ) {
  302.     prev_mytime=mytime;
  303.  
  304.     
  305.     st[0]='\0';
  306.     qsec2str(st,stat_time);
  307.     vt_home();
  308.     printf(
  309.     VT_GOTOXY("1","1")
  310.     VT_CLREOL
  311.                            STYLE_STATTEXT   "Bytes saved:"
  312.                            STYLE_STATVALUES " \t%s"
  313.                            "\t"
  314.     VT_CLREOL
  315.     VT_GOTOXY("40","1")
  316.                            STYLE_STATTEXT   "Links scanned:"
  317.                            STYLE_STATVALUES " \t%d/%d (+%d)"
  318.     VT_CLREOL"\n"VT_CLREOL
  319.     VT_GOTOXY("1","2")
  320.                            STYLE_STATTEXT   "Time:"
  321.                                             " \t"
  322.                            STYLE_STATVALUES "%s"
  323.                            "\t"
  324.     VT_CLREOL
  325.     VT_GOTOXY("40","2")
  326.                            STYLE_STATTEXT   "Files written:"
  327.                                             " \t"
  328.                            STYLE_STATVALUES "%d"
  329.     VT_CLREOL"\n"VT_CLREOL
  330.     VT_GOTOXY("1","3")
  331.                            STYLE_STATTEXT   "Transfer rate:"
  332.                                             " \t"
  333.                            STYLE_STATVALUES "%s (%s)"
  334.                            "\t"
  335.     VT_CLREOL
  336.     VT_GOTOXY("40","3")
  337.                            STYLE_STATTEXT   "Files updated:"
  338.                                             " \t"
  339.                            STYLE_STATVALUES "%d"
  340.     VT_CLREOL"\n"VT_CLREOL
  341.     VT_GOTOXY("1","4")
  342.                            STYLE_STATTEXT   "Active connections:"
  343.                                             " \t"
  344.                            STYLE_STATVALUES "%d"
  345.                            "\t"
  346.     VT_CLREOL
  347.     VT_GOTOXY("40","4")
  348.                            STYLE_STATTEXT   "Errors:"
  349.                            STYLE_STATVALUES " \t"
  350.                            STYLE_STATVALUES "%d"
  351.     VT_CLREOL"\n"
  352.     STYLE_STATRESET
  353.     ,
  354.       /* */
  355.       (char*)int2bytes(SInfo.stat_bytes),
  356.       (int)lien_n,(int)SInfo.lien_tot,(int)nbk,
  357.       (char*)st,
  358.       (int)SInfo.stat_written,
  359.       (char*)int2bytessec(SInfo.irate),(char*)int2bytessec(SInfo.rate),
  360.       (int)SInfo.stat_updated,
  361.       (int)SInfo.stat_nsocket,
  362.       (int)SInfo.stat_errors
  363.       /* */
  364.       );
  365.  
  366.     
  367.     // parcourir registre des liens
  368.     if (back_index>=0) {  // seulement si index passΘ
  369.       int j,k;
  370.       int index=0;
  371.       int ok=0;         // idem
  372.       int l;            // idem
  373.       //
  374.       t_StatsBuffer StatsBuffer[NStatsBuffer];
  375.       
  376.       {
  377.         int i;
  378.         for(i=0;i<NStatsBuffer;i++) {
  379.           strcpybuff(StatsBuffer[i].state,"");
  380.           strcpybuff(StatsBuffer[i].name,"");
  381.           strcpybuff(StatsBuffer[i].file,"");
  382.           strcpybuff(StatsBuffer[i].url_sav,"");
  383.           StatsBuffer[i].back=0;
  384.           StatsBuffer[i].size=0;
  385.           StatsBuffer[i].sizetot=0;
  386.         }
  387.       }
  388.       for(k=0;k<2;k++) {    // 0: lien en cours 1: autres liens
  389.         for(j=0;(j<3) && (index<NStatsBuffer);j++) {  // passe de prioritΘ
  390.           int _i;
  391.           for(_i=0+k;(_i< max(back_max*k,1) ) && (index<NStatsBuffer);_i++) {  // no lien
  392.             int i=(back_index+_i)%back_max;    // commencer par le "premier" (l'actuel)
  393.             if (back[i].status>=0) {     // signifie "lien actif"
  394.               // int ok=0;  // OPTI
  395.               ok=0;
  396.               switch(j) {
  397.               case 0:     // prioritaire
  398.                 if ((back[i].status>0) && (back[i].status<99)) {
  399.                   strcpybuff(StatsBuffer[index].state,"receive"); ok=1;
  400.                 }
  401.                 break;
  402.               case 1:
  403.                 if (back[i].status==99) {
  404.                   strcpybuff(StatsBuffer[index].state,"request"); ok=1;
  405.                 }
  406.                 else if (back[i].status==100) {
  407.                   strcpybuff(StatsBuffer[index].state,"connect"); ok=1;
  408.                 }
  409.                 else if (back[i].status==101) {
  410.                   strcpybuff(StatsBuffer[index].state,"search"); ok=1;
  411.                 }
  412.                 else if (back[i].status==1000) {    // ohh le beau ftp
  413.                   sprintf(StatsBuffer[index].state,"ftp: %s",back[i].info); ok=1;
  414.                 }
  415.                 break;
  416.               default:
  417.                 if (back[i].status==0) {  // prΩt
  418.                   if ((back[i].r.statuscode==200)) {
  419.                     strcpybuff(StatsBuffer[index].state,"ready"); ok=1;
  420.                   }
  421.                   else if ((back[i].r.statuscode>=100) && (back[i].r.statuscode<=599)) {
  422.                     char tempo[256]; tempo[0]='\0';
  423.                     infostatuscode(tempo,back[i].r.statuscode);
  424.                     strcpybuff(StatsBuffer[index].state,tempo); ok=1;
  425.                   }
  426.                   else {
  427.                     strcpybuff(StatsBuffer[index].state,"error"); ok=1;
  428.                   }
  429.                 }
  430.                 break;
  431.               }
  432.               
  433.               if (ok) {
  434.                 char s[HTS_URLMAXSIZE*2];
  435.                 //
  436.                 StatsBuffer[index].back=i;        // index pour + d'infos
  437.                 //
  438.                 s[0]='\0';
  439.                 strcpybuff(StatsBuffer[index].url_sav,back[i].url_sav);   // pour cancel
  440.                 if (strcmp(back[i].url_adr,"file://"))
  441.                   strcatbuff(s,back[i].url_adr);
  442.                 else
  443.                   strcatbuff(s,"localhost");
  444.                 if (back[i].url_fil[0]!='/')
  445.                   strcatbuff(s,"/");
  446.                 strcatbuff(s,back[i].url_fil);
  447.                 
  448.                 StatsBuffer[index].file[0]='\0';
  449.                 {
  450.                   char* a=strrchr(s,'/');
  451.                   if (a) {
  452.                     strncatbuff(StatsBuffer[index].file,a,200);
  453.                     *a='\0';
  454.                   }
  455.                 }
  456.                 
  457.                 if ((l=strlen(s))<MAX_LEN_INPROGRESS)
  458.                   strcpybuff(StatsBuffer[index].name,s);
  459.                 else {
  460.                   // couper
  461.                   StatsBuffer[index].name[0]='\0';
  462.                   strncatbuff(StatsBuffer[index].name,s,MAX_LEN_INPROGRESS/2-2);
  463.                   strcatbuff(StatsBuffer[index].name,"...");
  464.                   strcatbuff(StatsBuffer[index].name,s+l-MAX_LEN_INPROGRESS/2+2);
  465.                 }
  466.                                
  467.                 if (back[i].r.totalsize>0) {  // taille prΘdΘfinie
  468.                   StatsBuffer[index].sizetot=back[i].r.totalsize;
  469.                   StatsBuffer[index].size=back[i].r.size;
  470.                 } else {  // pas de taille prΘdΘfinie
  471.                   if (back[i].status==0) {  // prΩt
  472.                     StatsBuffer[index].sizetot=back[i].r.size;
  473.                     StatsBuffer[index].size=back[i].r.size;
  474.                   } else {
  475.                     StatsBuffer[index].sizetot=8192;
  476.                     StatsBuffer[index].size=(back[i].r.size % 8192);
  477.                   }
  478.                 }
  479.                 index++;
  480.               }
  481.             }
  482.           }
  483.         }
  484.       }
  485.  
  486.       /* LF */
  487.       printf("%s\n",VT_CLREOL);
  488.  
  489.       /* Display current job */
  490.       {
  491.         int parsing=0;
  492.         printf("Current job: ");
  493.         if (!(parsing=hts_is_parsing(-1)))
  494.           printf("receiving files");
  495.         else {
  496.           switch(hts_is_testing()) {
  497.           case 0:
  498.             printf("parsing HTML file (%d%%)",parsing);
  499.             break;
  500.           case 1:
  501.             printf("parsing HTML file: testing links (%d%%)",parsing);
  502.             break;
  503.           case 2:
  504.             printf("purging files");
  505.             break;
  506.           }
  507.         }
  508.         printf("%s\n",VT_CLREOL);
  509.       }
  510.       
  511.       /* Display background jobs */
  512.       {
  513.         int i;
  514.         for(i=0;i<NStatsBuffer;i++) {
  515.           if (strnotempty(StatsBuffer[i].state)) {
  516.             printf(VT_CLREOL" %s - \t%s%s \t%s / \t%s",
  517.               StatsBuffer[i].state,
  518.               StatsBuffer[i].name,
  519.               StatsBuffer[i].file,
  520.               int2bytes(StatsBuffer[i].size),
  521.               int2bytes(StatsBuffer[i].sizetot)
  522.               );
  523.           }
  524.           printf("%s\n",VT_CLREOL);
  525.         }
  526.       }
  527.  
  528.  
  529.     }
  530.  
  531.   }
  532.  
  533.  
  534.  
  535.   return 1;
  536. }
  537. char* __cdecl htsshow_query(char* question) {
  538.   static char s[12]=""; /* ok */
  539.   printf("%s\nPress <Y><Enter> to confirm, <N><Enter> to abort\n",question);
  540.   io_flush; linput(stdin,s,4);
  541.   return s;
  542. }
  543. char* __cdecl htsshow_query2(char* question) {
  544.   static char s[12]=""; /* ok */
  545.   printf("%s\nPress <Y><Enter> to confirm, <N><Enter> to abort\n",question);
  546.   io_flush; linput(stdin,s,4);
  547.   return s;
  548. }
  549. char* __cdecl htsshow_query3(char* question) {
  550.   static char line[256]; /* ok */
  551.   do {
  552.     io_flush; linput(stdin,line,206);
  553.   } while(!strnotempty(line));
  554.   printf("ok..\n");
  555.   return line;
  556. }
  557. int __cdecl htsshow_check(char* adr,char* fil,int status) {
  558.   return -1;
  559. }
  560. void __cdecl htsshow_pause(char* lockfile) {
  561.   while (fexist(lockfile)) {
  562.     Sleep(1000);
  563.   }
  564. }
  565. void __cdecl htsshow_filesave(char* file) {
  566. }
  567. int __cdecl htsshow_linkdetected(char* link) {
  568.   return 1;
  569. }
  570. int __cdecl htsshow_xfrstatus(lien_back* back) {
  571.   return 1;
  572. }
  573. int __cdecl htsshow_savename(char* adr_complete,char* fil_complete,char* referer_adr,char* referer_fil,char* save) {
  574.   return 1;
  575. }
  576.  
  577.  
  578. /* *** Various functions *** */
  579.  
  580.  
  581. int fexist(char* s) {
  582.   struct stat st;
  583.   memset(&st, 0, sizeof(st));
  584.   if (stat(s, &st) == 0) {
  585.     if (S_ISREG(st.st_mode)) {
  586.       return 1;
  587.     }
  588.   }
  589.   return 0;
  590.  
  591. int linput(FILE* fp,char* s,int max) {
  592.   int c;
  593.   int j=0;
  594.   do {
  595.     c=fgetc(fp);
  596.     if (c!=EOF) {
  597.       switch(c) {
  598.         case 13: break;  // sauter CR
  599.         case 10: c=-1; break;
  600.         case 9: case 12: break;  // sauter ces caractΦres
  601.         default: s[j++]=(char) c; break;
  602.       }
  603.     }
  604.   }  while((c!=-1) && (c!=EOF) && (j<(max-1)));
  605.   s[j]='\0';
  606.   return j;
  607. }
  608.  
  609. #endif
  610.